package com.web.java0328springboot.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.web.java0328springboot.entity.User;
import com.web.java0328springboot.mapper.UserMapper;
import com.web.java0328springboot.service.UserService;

import org.springframework.stereotype.Service;

/**
 * @author lenovo
 * @Description
 * @Date2025/3/28 下午2:43
 */

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>implements UserService {

//    @Resource
//    private UserMapper userMapper;

    @Override
    public User login(String username, String password) {
        //按用户名查询用户
        User user = getOne(new QueryWrapper<User>().lambda()
                .eq(User::getUsername,username));
        if(user != null){
            //判断密码是否正确
            if(password.equals(user.getPassword())){
                return user;
            }
        }
        return null;
    }
}
